﻿<UserControl x:Class="Core.Views.Parameters"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:class="clr-namespace:Core.Class"
             xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:helpers="clr-namespace:Helpers;assembly=Helpers"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d">
    <UserControl.Resources>

        <Style x:Key="ButtonResetDefault" TargetType="{x:Type Button}">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <TextBlock x:Name="text"
                                   VerticalAlignment="Center"
                                   FontSize="12"
                                   Foreground="{DynamicResource ColorThemeBrush}"
                                   Text="{TemplateBinding Content}" />
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="text" Property="TextBlock.TextDecorations" Value="Underline" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="text" Property="Foreground" Value="{StaticResource ColorThemeDarkBrush}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="TreeViewParams" TargetType="{x:Type TreeView}">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="ItemContainerStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="TreeViewItem.IsExpanded" Value="True" />
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Key="ParameterDefault">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           FontSize="10pt"
                           Text="{Binding Libelle,
                                          StringFormat='- {0} :'}"
                           TextWrapping="Wrap" />
                <TextBox Grid.Column="1"
                         MinWidth="100"
                         Margin="5,0,0,0"
                         HorizontalAlignment="Left"
                         FontSize="10pt"
                         Padding="5,0,5,0"
                         Text="{Binding Valeur,
                                        Mode=TwoWay}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ParameterBoolean">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <CheckBox Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,5,0,5"
                          Content="{Binding Libelle}"
                          FontSize="10pt"
                          IsChecked="{Binding Valeur,
                                              Mode=TwoWay,
                                              Converter={StaticResource StringToBooleanConverter}}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ParameterLimited">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           FontSize="10pt"
                           Text="{Binding Libelle,
                                          StringFormat='- {0} :'}"
                           TextWrapping="Wrap" />
                <StackPanel Grid.Column="1"
                            Margin="0,5,0,5"
                            Orientation="Vertical">
                    <Slider IsSnapToTickEnabled="True"
                            Maximum="{Binding MaxValue}"
                            Minimum="{Binding MinValue}"
                            TickFrequency="{Binding Pas}"
                            Value="{Binding Valeur}" />
                    <TextBlock Margin="0,5,0,0"
                               HorizontalAlignment="Center"
                               FontSize="10pt"
                               Text="{Binding Valeur}" />
                </StackPanel>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ParameterDefaultUser">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           FontSize="10pt"
                           Text="{Binding Libelle,
                                          StringFormat='- {0} :'}"
                           TextWrapping="Wrap" />
                <TextBox Grid.Column="1"
                         MinWidth="100"
                         Margin="5,0,0,0"
                         HorizontalAlignment="Left"
                         FontSize="10pt"
                         Padding="5,0,5,0"
                         Text="{Binding Valeur,
                                        Mode=TwoWay}" />
                <Button Grid.Column="2"
                        Margin="10,0,0,0"
                        Command="{Binding Path=DataContext.InitDefaultCommand,
                                          RelativeSource={RelativeSource Mode=FindAncestor,
                                                                         AncestorLevel=1,
                                                                         AncestorType=UserControl}}"
                        CommandParameter="{Binding}"
                        Content="{helpers:Localize Parameter_InitialValue}"
                        Style="{StaticResource ButtonResetDefault}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ParameterBooleanUser">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <CheckBox Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,5,0,5"
                          Content="{Binding Libelle}"
                          FontSize="10pt"
                          IsChecked="{Binding Valeur,
                                              Mode=TwoWay,
                                              Converter={StaticResource StringToBooleanConverter}}" />
                <Button Grid.Column="2"
                        Margin="10,0,0,0"
                        Command="{Binding InitDefaultCommand}"
                        Content="{helpers:Localize Parameter_InitialValue}"
                        Style="{StaticResource ButtonResetDefault}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ParameterLimitedUser">
            <Grid Margin="0,5,0,5" HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="500" />
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           FontSize="10pt"
                           Text="{Binding Libelle,
                                          StringFormat='- {0} :'}"
                           TextWrapping="Wrap" />
                <StackPanel Grid.Column="1"
                            Margin="0,5,0,5"
                            Orientation="Vertical">
                    <Slider IsSnapToTickEnabled="True"
                            Maximum="{Binding MaxValue}"
                            Minimum="{Binding MinValue}"
                            TickFrequency="{Binding Pas}"
                            Value="{Binding Valeur}" />
                    <TextBlock Margin="0,5,0,0"
                               HorizontalAlignment="Center"
                               FontSize="10pt"
                               Text="{Binding Valeur}" />
                </StackPanel>
                <Button Grid.Column="2"
                        Margin="10,0,0,0"
                        VerticalAlignment="Top"
                        Command="{Binding InitDefaultCommand}"
                        Content="{helpers:Localize Parameter_InitialValue}"
                        Style="{StaticResource ButtonResetDefault}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="TemplateUtilisateur">
            <Grid Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition Width="120" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           VerticalAlignment="Center"
                           FontSize="10pt"
                           Foreground="{DynamicResource ColorThemeBrush}"
                           Text="{Binding}" />
                <Button Grid.Column="1"
                        Margin="15,0,0,0"
                        VerticalAlignment="Center"
                        Command="{Binding Path=DataContext.DeleteUserCommand,
                                          RelativeSource={RelativeSource Mode=FindAncestor,
                                                                         AncestorLevel=1,
                                                                         AncestorType=UserControl}}"
                        CommandParameter="{Binding}"
                        Content="{helpers:Localize Parameter_DeleteUser}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="TemplateGroupe">
            <Grid Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition Width="120" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0"
                           VerticalAlignment="Center"
                           FontSize="10pt"
                           Foreground="{DynamicResource ColorThemeBrush}"
                           Text="{Binding Code}" />
                <Button Grid.Column="1"
                        Margin="15,0,0,0"
                        VerticalAlignment="Center"
                        Command="{Binding Path=DataContext.DeleteGroupeCommand,
                                          RelativeSource={RelativeSource Mode=FindAncestor,
                                                                         AncestorLevel=1,
                                                                         AncestorType=UserControl}}"
                        CommandParameter="{Binding}"
                        Content="{helpers:Localize Parameter_DeleteGroupe}" />
            </Grid>
        </DataTemplate>

        <class:ParameterTemplateSelector x:Key="ParameterTemplateSelectorUser"
                                         BooleanTemplate="{StaticResource ParameterBooleanUser}"
                                         DefaultTemplate="{StaticResource ParameterDefaultUser}"
                                         LimitedTemplate="{StaticResource ParameterLimitedUser}" />
        <class:ParameterTemplateSelector x:Key="ParameterTemplateSelector"
                                         BooleanTemplate="{StaticResource ParameterBoolean}"
                                         DefaultTemplate="{StaticResource ParameterDefault}"
                                         LimitedTemplate="{StaticResource ParameterLimited}" />

        <Style x:Key="ExpanderRights" TargetType="{x:Type Expander}">
            <Style.Resources>
                <Style x:Key="ToggleButtonExpanded" TargetType="{x:Type ToggleButton}">
                    <Setter Property="Cursor" Value="Hand" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="MouseOver" />
                                            <VisualState x:Name="Pressed" />
                                            <VisualState x:Name="Disabled" />
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="CheckStates">
                                            <VisualState x:Name="Checked">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="buttonExpander" Storyboard.TargetProperty="(Button.RenderTransform).(RotateTransform.Angle)">
                                                        <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="0">
                                                            <EasingDoubleKeyFrame.EasingFunction>
                                                                <ExponentialEase EasingMode="EaseOut" Exponent="6" />
                                                            </EasingDoubleKeyFrame.EasingFunction>
                                                        </EasingDoubleKeyFrame>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Unchecked">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="buttonExpander" Storyboard.TargetProperty="(Button.RenderTransform).(RotateTransform.Angle)">
                                                        <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="-90">
                                                            <EasingDoubleKeyFrame.EasingFunction>
                                                                <ExponentialEase EasingMode="EaseOut" Exponent="6" />
                                                            </EasingDoubleKeyFrame.EasingFunction>
                                                        </EasingDoubleKeyFrame>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="FocusStates">
                                            <VisualState x:Name="Focused" />
                                            <VisualState x:Name="Unfocused" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="20" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <Border x:Name="buttonExpander"
                                            Grid.Column="0"
                                            CornerRadius="{DynamicResource CornerRadiusSize}"
                                            RenderTransformOrigin="0.5,0.5">
                                        <Path Width="8"
                                              Height="8"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Data="M 0,0 L0.5,1 L1,0Z"
                                              Fill="{DynamicResource ColorThemeBrush}"
                                              Stretch="Fill" />
                                        <Border.RenderTransform>
                                            <RotateTransform />
                                        </Border.RenderTransform>
                                    </Border>
                                    <TextBlock Grid.Column="1"
                                               Margin="4"
                                               FontSize="13pt"
                                               Text="{Binding Path=Content,
                                                              RelativeSource={RelativeSource TemplatedParent}}" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Style.Resources>
            <Setter Property="IsExpanded" Value="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, AncestorLevel=1}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Expander">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Name="ContentRow" Height="0" />
                            </Grid.RowDefinitions>
                            <Border Name="Border" Grid.Row="0">
                                <ToggleButton Content="{TemplateBinding Header}"
                                              IsChecked="{Binding Path=IsExpanded,
                                                                  Mode=TwoWay,
                                                                  RelativeSource={RelativeSource TemplatedParent}}"
                                              Style="{StaticResource ToggleButtonExpanded}" />
                            </Border>
                            <Border Name="Content"
                                    Grid.Row="1"
                                    Background="Transparent">
                                <ContentPresenter Margin="4" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content, Path=DesiredHeight}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Key="ThemeTemplate">
            <TextBlock Text="{Binding Name, Converter={StaticResource LocalizeConverter}}" />
        </DataTemplate>

        <Style x:Key="AccentColorItemStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="BorderColor"
                                Width="25"
                                Height="25"
                                Margin="0,0,5,0"
                                Background="{Binding AccentColor,
                                                     Converter={StaticResource ColorToSolidColorBrushConverter}}"
                                BorderBrush="Transparent"
                                BorderThickness="2" />
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="BorderColor" Property="BorderBrush" Value="LightGray" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>

    <controls:MetroContentControl Margin="20">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="80" />
            </Grid.RowDefinitions>

            <Grid Grid.Row="0"
                  Grid.Column="0"
                  Margin="20"
                  Background="White">

                <TabControl Margin="10">

                    <!--  Paramétres utilisateur  -->
                    <TabItem Foreground="{DynamicResource LabelForegroundBrush}" Header="{helpers:Localize Parameter_UserParamTabItem}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!--  Liste des paramètres de l'utilisateur  -->
                            <TreeView Grid.Row="0"
                                      ItemsSource="{Binding ParamsUserModules}"
                                      Style="{StaticResource TreeViewParams}">
                                <TreeView.ItemTemplate>
                                    <HierarchicalDataTemplate ItemTemplateSelector="{StaticResource ParameterTemplateSelectorUser}" ItemsSource="{Binding Parameters}">
                                        <TextBlock FontSize="13pt" Text="{Binding Header}" />
                                    </HierarchicalDataTemplate>
                                </TreeView.ItemTemplate>
                            </TreeView>

                            <!--  Choix du théme  -->
                            <Grid Grid.Row="1"
                                  Margin="20,5,0,20"
                                  HorizontalAlignment="Left">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <!--  Thémes  -->
                                <StackPanel Grid.Column="0"
                                            Width="450"
                                            Orientation="Vertical">
                                    <Label Content="{helpers:Localize Parameter_ChoixTheme}" />
                                    <ComboBox Width="250"
                                              Margin="5,5,0,0"
                                              HorizontalAlignment="Left"
                                              ItemTemplate="{StaticResource ThemeTemplate}"
                                              ItemsSource="{Binding Themes}"
                                              SelectedItem="{Binding SelectedTheme,
                                                                     Mode=TwoWay}" />
                                </StackPanel>

                                <!--  Couleurs d'accentuation  -->
                                <StackPanel Grid.Column="1"
                                            Margin="10,0,0,0"
                                            Orientation="Vertical">
                                    <Label Content="{helpers:Localize Parameter_ChoixAccentColor}" />
                                    <ListBox Width="250"
                                             Margin="5,5,0,0"
                                             HorizontalAlignment="Left"
                                             ItemContainerStyle="{StaticResource AccentColorItemStyle}"
                                             ItemsSource="{Binding AccentColors}"
                                             SelectedItem="{Binding SelectedAccentColor,
                                                                    Mode=TwoWay}"
                                             Style="{StaticResource ListBoxTransparentHorizontal}" />
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </TabItem>

                    <!--  Paramétres systéme  -->
                    <TabItem Foreground="{DynamicResource LabelForegroundBrush}"
                             Header="{helpers:Localize Parameter_SystemParamTabItem}"
                             Visibility="{helpers:AccessFunctionVisibility 1,
                                                                           Core}">
                        <TreeView ItemsSource="{Binding ParamsSystemModules}" Style="{StaticResource TreeViewParams}">
                            <TreeView.ItemTemplate>
                                <HierarchicalDataTemplate ItemTemplateSelector="{StaticResource ParameterTemplateSelector}" ItemsSource="{Binding Parameters}">
                                    <TextBlock FontSize="13pt" Text="{Binding Header}" />
                                </HierarchicalDataTemplate>
                            </TreeView.ItemTemplate>
                        </TreeView>
                    </TabItem>

                    <!--  Gestion des droits  -->
                    <TabItem Foreground="{DynamicResource LabelForegroundBrush}"
                             Header="{helpers:Localize Parameter_RightsTabItem}"
                             Visibility="{helpers:AccessFunctionVisibility 2,
                                                                           Core}">

                        <ListBox>
                            <ListBox.Template>
                                <ControlTemplate TargetType="{x:Type ListBox}">
                                    <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                                </ControlTemplate>
                            </ListBox.Template>
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="{x:Type ListBoxItem}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                                <ContentPresenter Content="{TemplateBinding Content}" Margin="10,0,40,0" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListBox.ItemContainerStyle>

                            <!--  Utilisateurs  -->
                            <Expander Header="{helpers:Localize Parameter_UserTitle}"
                                      IsExpanded="True"
                                      Style="{StaticResource ExpanderRights}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <ListBox Margin="10"
                                             ItemTemplate="{StaticResource TemplateUtilisateur}"
                                             ItemsSource="{Binding Utilisateurs}"
                                             SelectedItem="{Binding SelectedUtilisateur,
                                                                    Mode=TwoWay}" />

                                    <Button Grid.Column="1"
                                            Height="50"
                                            Margin="20,8,0,0"
                                            VerticalAlignment="Top"
                                            Command="{Binding AddUserCommand}"
                                            Style="{StaticResource MetroFlatButtonSteviaWithPicture}"
                                            Tag="{helpers:Localize Parameter_NewUser}">
                                        <Button.RenderTransform>
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </Button.RenderTransform>
                                        <Button.Content>
                                            <Viewbox Width="30.232" Height="24.335">
                                                <Canvas Width="30.232" Height="24.335">
                                                    <Canvas>
                                                        <Path Data="F1 M 1.638,22.698 L 18.828,22.698 L 18.828,11.033 L 1.638,11.033 L 1.638,22.698 Z M 20.465,24.335 L 0.000,24.335 L 0.000,9.396 L 20.465,9.396 L 20.465,24.335 Z" Fill="White" />
                                                        <Path Data="F1 M 7.163,12.262 L 2.865,21.470 L 17.600,21.470 L 13.916,16.559 L 11.665,18.400 L 7.163,12.262 Z" Fill="White" />
                                                        <Path Data="F1 M 15.758,12.465 C 16.549,12.465 17.190,13.106 17.190,13.898 C 17.190,14.689 16.549,15.331 15.758,15.331 C 14.966,15.331 14.324,14.689 14.324,13.898 C 14.324,13.106 14.966,12.465 15.758,12.465 Z" Fill="White" />
                                                        <Path Data="F1 M 23.182,0.000 L 26.813,0.000 L 26.813,3.421 L 30.232,3.421 L 30.232,7.041 L 26.841,7.041 L 26.841,10.456 L 23.195,10.456 L 23.195,7.041 L 19.774,7.041 L 19.774,3.421 L 23.182,3.421 L 23.182,0.000 Z" Fill="White" />
                                                    </Canvas>
                                                </Canvas>
                                            </Viewbox>
                                        </Button.Content>
                                    </Button>
                                </Grid>
                            </Expander>

                            <!--  Groupes  -->
                            <Expander Header="{helpers:Localize Parameter_GroupesTitle}" Style="{StaticResource ExpanderRights}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <ListBox Margin="10"
                                             ItemTemplate="{StaticResource TemplateGroupe}"
                                             ItemsSource="{Binding Groupes}"
                                             SelectedItem="{Binding SelectedGroupe,
                                                                    Mode=TwoWay}" />

                                    <Button Grid.Column="1"
                                            Height="50"
                                            Margin="20,8,0,0"
                                            VerticalAlignment="Top"
                                            Command="{Binding AddGroupeCommand}"
                                            Style="{StaticResource MetroFlatButtonSteviaWithPicture}"
                                            Tag="{helpers:Localize Parameter_NewGroupe}">
                                        <Button.RenderTransform>
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </Button.RenderTransform>
                                        <Button.Content>
                                            <Viewbox Width="30.232" Height="24.335">
                                                <Canvas Width="30.232" Height="24.335">
                                                    <Canvas>
                                                        <Path Data="F1 M 1.638,22.698 L 18.828,22.698 L 18.828,11.033 L 1.638,11.033 L 1.638,22.698 Z M 20.465,24.335 L 0.000,24.335 L 0.000,9.396 L 20.465,9.396 L 20.465,24.335 Z" Fill="White" />
                                                        <Path Data="F1 M 7.163,12.262 L 2.865,21.470 L 17.600,21.470 L 13.916,16.559 L 11.665,18.400 L 7.163,12.262 Z" Fill="White" />
                                                        <Path Data="F1 M 15.758,12.465 C 16.549,12.465 17.190,13.106 17.190,13.898 C 17.190,14.689 16.549,15.331 15.758,15.331 C 14.966,15.331 14.324,14.689 14.324,13.898 C 14.324,13.106 14.966,12.465 15.758,12.465 Z" Fill="White" />
                                                        <Path Data="F1 M 23.182,0.000 L 26.813,0.000 L 26.813,3.421 L 30.232,3.421 L 30.232,7.041 L 26.841,7.041 L 26.841,10.456 L 23.195,10.456 L 23.195,7.041 L 19.774,7.041 L 19.774,3.421 L 23.182,3.421 L 23.182,0.000 Z" Fill="White" />
                                                    </Canvas>
                                                </Canvas>
                                            </Viewbox>
                                        </Button.Content>
                                    </Button>
                                </Grid>
                            </Expander>
                        </ListBox>
                    </TabItem>
                </TabControl>
            </Grid>

            <!--  Fermeture  -->
            <StackPanel Grid.Row="1"
                        Margin="20,10,20,20"
                        HorizontalAlignment="Right"
                        Orientation="Horizontal">
                <Button Command="{Binding SaveAndCloseCommand}"
                        Content="{helpers:Localize Parameter_SaveAndClose}"
                        Style="{DynamicResource MetroFlatButtonStevia}" />
            </StackPanel>
        </Grid>
    </controls:MetroContentControl>
</UserControl>
